<template>
    <div class="photoinfo-container">
        <h3 class="title">{{info.title}}</h3>
        <p class="info">
            <span>添加时间：{{info.add_time | dateFormat}}</span>
            <span>点击次数：{{info.click}}</span>
        </p>
        <hr>

        <div class="thumbs">
            <img class="preview-img" v-for="(item, index) in list" :src="item.src" height="100" @tap="$preview.open(index, list)" :key="item.src">
        </div>

        <div class="content">
            {{info.content}}
        </div>
        <comment-box :id="this.$route.params.id"></comment-box>
    </div>
</template>
<script>
    // 导入评论组件
    import comment from '../subcomponents/comment.vue';
    export default {
        data() {
            return {
                info: {},
                list: []
            }
        },
        created() {
            this.getInfo();
            this.getThumes();
        },
        methods: {
            getInfo() {
                this.$http.get('http://vue.studyit.io/api/getimageInfo/'+this.$route.params.id).then(result=>{
                    this.info = result.body.message[0];
                });
            },
            getThumes() {
                this.$http.get('http://vue.studyit.io/api/getthumimages/'+this.$route.params.id).then(result=>{
                    result.body.message.forEach(item => {
                        item.w = 600;
                        item.h = 400;
                    });
                    this.list = result.body.message;
                    console.log(this.$preview);
                });
            }
        },
        components: {
            'comment-box' : comment
        }
    }
</script>
<style lang="less" scoped>
.photoinfo-container{
    padding:10px;
    .title{
        font-size: 16px;
        text-align: left;
    }
    .info {
        display: flex;
        justify-content: space-between;
    }
    .content{
        font-size: 14px;
    }
}
</style>
